<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSpotTradesTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('trading_spot_trades', function (Blueprint $table) {
            $table->increments('id');
            $table->string('symbol')->comment('交易对符号');
            $table->enum('side', ['BUY', 'SELL'])->comment('买入/卖出');
            $table->unsignedInteger('coin_id')->comment('币种ID');
            $table->unsignedInteger('market_id')->comment('交易区ID');
            $table->unsignedInteger('buy_user_id')->comment('买家ID');
            $table->unsignedInteger('sell_user_id')->comment('卖家ID');
            $table->unsignedInteger('buy_order_id')->comment('买订单ID');
            $table->unsignedInteger('sell_order_id')->comment('卖订单ID');
            $table->unsignedDecimal('price', 20, 8)->comment('成交价格');
            $table->unsignedDecimal('number', 20, 8)->comment('成交数量');
            $table->unsignedDecimal('buy_fee', 20, 8)->comment('买方手续费');
            $table->unsignedDecimal('sell_fee', 20, 8)->comment('卖方手续费');
            $table->timestamp('created_at')->nullable()->useCurrent()->comment('成交时间');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('trading_spot_trades');
    }
}
